package zmm

import (
	"context"
	"github.com/tiger1103/gfast/v3/api/v1/zmm"
	"github.com/tiger1103/gfast/v3/internal/app/system/controller"
	"github.com/tiger1103/gfast/v3/internal/app/zmm/service"
)

var ZmmOrder = zmmOrderController{}

type zmmOrderController struct {
	controller.BaseController
}

// List 列表
func (c *zmmOrderController) OrderList(ctx context.Context, req *zmm.ZmmOrderListReq) (res *zmm.ZmmOrderListRes, err error) {
	res = new(zmm.ZmmOrderListRes)
	res.Total, res.List, err = service.ZmmOrder().GetList(ctx, req)
	return
}

func (c *zmmOrderController) OrderEdit(ctx context.Context, req *zmm.ZmmOrderEditReq) (res *zmm.ZmmOrderEditRes, err error) {
	res = new(zmm.ZmmOrderEditRes)
	_, err = service.ZmmOrder().Edit(ctx, req)
	if err != nil {
		return nil, err
	}
	return
}

func (c *zmmOrderController) OrderDelete(ctx context.Context, req *zmm.ZmmOrderDelReq) (res *zmm.ZmmOrderDelRes, err error) {
	res = new(zmm.ZmmOrderDelRes)
	err = service.ZmmOrder().Delete(ctx, req)
	return
}
